// pages/jp_guanli/jp_guanli.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    appurl: app.apiurl,
    apiimg: app.apiimg,
    idx:1,
    list:[],
    yonghu:'',
    tanchuang17:false,
    tanchuang27:false,
    page_no:1,
    shiwutan:false
  },
  z_tapbar(e) {
    let index = e.currentTarget.dataset.id
    this.setData({
      idx: index
    })
  },
  z_open1(e){
    let _this = this
    _this.setData({
      name:e.currentTarget.dataset.name,
      ffsl_num:e.currentTarget.dataset.ffsl_num,
      ff_time:e.currentTarget.dataset.ff_time,
      kdgs:e.currentTarget.dataset.kdgs,
      kddh:e.currentTarget.dataset.kddh,
      tanchuang17:true
     })
  },
  z_open2(e){
    let _this = this
    _this.setData({
      name:e.currentTarget.dataset.name,
      ff_status:e.currentTarget.dataset.ff_status,
      ff_num:e.currentTarget.dataset.ff_num,
      ff_time:e.currentTarget.dataset.ff_time,
      lj_remark:e.currentTarget.dataset.lj_remark,
      xnczzh:e.currentTarget.dataset.xnczzh,
      czmm:e.currentTarget.dataset.czmm,
      tanchuang27:true
    })
 },
 z_close(){
  this.setData({
    tanchuang17:false,
    tanchuang27:false
  })
},
z_close1(){
  this.setData({
    shiwutan:false,
  })
  wx.navigateTo({
    url: '/packageA/pages/addshow/addshow',
  })
},
fuzhi1(){
  let _this = this
  wx.setClipboardData({
    data: _this.data.kddh,
    success (res) {
      wx.getClipboardData({
        success (res) {
          console.log(res.data) // data
          wx.showToast({
            title: '复制成功',
            icon: 'success',
            duration: 2000
          })
        }
      })
    }
  })
},
fuzhi2(){
  let _this = this
  wx.setClipboardData({
    data: _this.data.xnczzh,
    success (res) {
      wx.getClipboardData({
        success (res) {
          console.log(res.data) // data
          wx.showToast({
            title: '复制成功',
            icon: 'success',
            duration: 2000
          })
        }
      })
    }
  })
},
fuzhi3(){
  let _this = this
  wx.setClipboardData({
    data: _this.data.czmm,
    success (res) {
      wx.getClipboardData({
        success (res) {
          console.log(res.data) // data
          wx.showToast({
            title: '复制成功',
            icon: 'success',
            duration: 2000
          })
        }
      })
    }
  })
},
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.z_yonghu()
  },
  z_jiangpin(){
    let _this = this
    let params = {
      "token":wx.getStorageSync("user_token"),
    }
    wx.request({
      url: app.apiurl + 'api/member/memberPrizeList?page_no=' + _this.data.page_no + '&page_num=100',
      method: 'GET',
      data: params,
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 修改请求
      },
      success(res) {
         _this.setData({
           list:res.data.data.list
         })
         if(_this.data.yonghu.shr_name == ''){
          for(let i = 0; i < res.data.data.list.length; i++){
            if(res.data.data.list[i].con_type == '1'){
              _this.setData({
               shiwutan:true
              })
            }
          }
         }
      }
    })
  },
  z_yonghu(){
    let _this = this
    let params = {
      "token":wx.getStorageSync("user_token"),
    }
    wx.request({
      url: app.apiurl + 'api/member/myInfo',
      method: 'POST',
      data: params,
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 修改请求
      },
      success(res) {
       if(res.data.code == '1001'){
         _this.setData({
           login:true,
           yonghu:res.data.data
         })
       }
       _this.z_jiangpin()
       if(res.data.data.yd_status == '0'){
         _this.setData({
           yindao1:true
         })
       } else if(res.data.data.member_level == '2'){
        _this.setData({
          yindao2:true
        })
      }
      }
    })
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
 //下滑刷新
//  let _this = this
//  let page_no  = _this.data.page_no
//  page_no = page_no+1
//  let page_no1  = _this.data.page_no1
//  page_no1 = page_no1+1
//  _this.setData({
//    page_no:page_no,
//    page_no1:page_no1
//  })
//  _this.z_jiangpin()
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})